<template>
	<view>
		<!-- 顶部选择栏 -->
		<view class="top_card">
			<!-- 选择项目阶段 -->
			<view class="top_card_line" @click="stageShow()">
				<text :style="project_stage == '选择项目阶段'?'color: #B2B2B2;':''">{{ project_stage }}</text>
			</view>
			<!-- 项目阶段选择 -->
			<view class="stage_select" v-show="stage_select_show">
				<!-- 左侧 -->
				<scroll-view scroll-y="true" class="stage_select_left">
					<view class="left_line"  v-for="(item,index) in stage_code_list" :style="index == stage_index? 'color: #128bf1;': ''" @click="stageLeftTab(item,index)">
						<text>{{item.label}}</text>
						<text style="position: absolute;right: 10rpx;"> > </text>
					</view>
				</scroll-view>
				<!-- 右侧 -->
				<scroll-view scroll-y="true" class="stage_select_right">
					<view class="left_line" v-for="(item,index) in stage_right_list" @click="stageRightTab(item,index)">
						<text>{{item.label}}</text>
					</view>
				</scroll-view>
			</view>
			<!-- 选择项目负责部门 -->
			<view class="top_card_line" @click="departmentShow()">
				<text :style="project_department == '选择项目负责部门'?'color: #B2B2B2;':''">{{project_department}}</text>
				
			</view>
			<!-- 负责部门 -->
			<view class="department_select" v-show="department_select_show">
				<view class="item" v-for="item in department_list" @click="setDepartment(item)">
					<text>{{item.department_name}}</text>
				</view>
			</view>
			<!-- 选择许可类型 -->
			<view class="top_card_line" @click="permitTypeShow()">
				<text :style="permit_type_select == '选择许可类型'?'color: #B2B2B2;':''">{{permit_type_select}}</text>
			</view>
			<!-- 许可类型 -->
			<view class="department_select" v-show="permit_type_select_show">
				<view class="item" v-for="item in radiolist" @click="setPermitType(item)">
					<text>{{item.text}}</text>
				</view>
			</view>
		</view>
		<!-- 查询按钮 -->
		<view class="query_btn" @click="getAdjustList()">
			查询
		</view>
		<!-- 流程展示 -->
		<view class="process">
			<view class="process_item" style="background-color: #30ad5f;width: 200rpx;">
				<text>开始</text>
			</view>
			<view class="botLine" ></view>
			
			<view class="" v-for="items in processList" style="display: flex;align-items: center;flex-direction: column;">
				<view class="process_item" style="padding-left: 20rpx;padding-right: 20rpx;">
					<text v-for="(item,index) in items" >{{index == items.length-1?item.nickname:item.nickname + '/'}}</text>
				</view>
				
				<view class="botLine"></view>
			</view>
			
			<view class="process_item" style="background-color: #f4a029;width: 200rpx;">
				<text>结束</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: '',
				member_id: '',
				company_id: '',
				stage_code: '',
				project_id: '', //项目id	
				project_type: '', //	项目负责部门
				permit_type: '', //许可类型
				permit_type_sub: '', //行业类型
				stage_right_list:[],
				stage_index:0,
				project_stage:'选择项目阶段',
				project_department:'选择项目负责部门',
				permit_type_select:'选择许可类型',
				permit_type_select_show:false,
				stage_select_show:false,
				department_select_show:false,
				department_list:'',
				processList:'',//项目流程
				radiolist: [{
						value: '2',
						text: '许可类'
					},
					{
						value: '1',
						text: '一般类'
					}
				],
				stage_code_list: [{
						value: '1',
						label: '立项',
						children: [{
								value: '11',
								label: '项目登记',
							},
							{
								value: '12',
								label: '项目分配',
							},
							{
								value: '13',
								label: '风险分析',
							},
							{
								value: '14',
								label: '项目组任命书',
							},
							{
								value: '15',
								label: '工作计划',
							},
						],
					},
					{
						value: '2',
						label: '现场调查',
						children: [{
								value: '21',
								label: '现场勘察记录',
							},
							{
								value: '22',
								label: '整改通知单',
							},
							{
								value: '23',
								label: '整改复查记录表',
							},
						],
					},
					{
						value: '3',
						label: '三级审查',
						children: [{
								value: '311',
								label: '项目内部审核意见表',
							},
							{
								value: '312',
								label: '修改回复表',
							},
							{
								value: '321',
								label: '技术负责人审核表',
							},
							{
								value: '322',
								label: '技术负责人审核修改回复表',
							},
							{
								value: '323',
								label: '过程控制负责人审核表',
							},
							{
								value: '324',
								label: '过程控制负责人修改回复表',
							},
						],
					},
					{
						value: '4',
						label: '外部审查',
						children: [{
							value: '33',
							label: '外部审查（非必须）',
						}, ],
					},
					{
						value: '5',
						label: '报告盖章',
						children: [{
							value: '44',
							label: '资质/印章使用申请',
						}, ],
					},
					{
						value: '5',
						label: '存档',
						children: [{
								value: '24',
								label: '委托方提供材料清单',
							},
							{
								value: '51',
								label: '项目档案存档清单',
							},
						],
					},
				],
			}
		},
		onLoad(val) {
			this.token = uni.getStorageSync('btlh_process_token') || '';
			this.member_id = uni.getStorageSync('btlh_process_member_id') || '';
			this.company_id = uni.getStorageSync('bthl_process_LoginCompanyId') || '';

			this.stage_code = val.stage_code || '';
			this.project_id = val.project_id || '';
			this.project_type = val.project_type || '';
			this.permit_type = val.permit_type || '';
			this.permit_type_sub = val.permit_type_sub || '';
			this.stage_right_list = this.stage_code_list[0].children;
			this.getAdjustList();
			this.getDepartment();
		},
		methods: {
			permitTypeShow(){
				this.permit_type_select_show = !this.permit_type_select_show;
				this.stage_select_show = false;
				this.department_select_show = false;
			},
			// 设置许可类型
			setPermitType(item){
				this.permit_type = item.value;
				this.permit_type_select = item.text;
				this.permit_type_select_show = false;
			},
			//设置部门
			setDepartment(item){
				this.project_department = item.department_name;
				this.project_type = item.department_id;
				this.department_select_show = false;
			},
			departmentShow(){
				this.department_select_show = !this.department_select_show;
				this.stage_select_show = false;
				this.permit_type_select_show = false;
			},
			
			// 获取部门
			async getDepartment(){
				const res =await this.$myRequest({
					url:'Project/is_business_department',
					method: 'GET',
					data:{
						member_id: this.member_id,
						token: this.token,
						company_id: this.company_id,
					}
				});
					if (res.data.code != 200)
					return uni.showToast({
						title: res.data.datas.msg,
						icon: 'none'
					});
					
					this.department_list = res.data.datas.listInfo;
			},
			
			stageShow(){
				this.stage_select_show = !this.stage_select_show;
				this.department_select_show = false;
				this.permit_type_select_show = false;
			},
			// 点击项目阶段左侧
			stageLeftTab(item,index){
				this.stage_index = index;
				this.stage_right_list = item.children;
			},
			
			// 点击项目阶段右侧
			stageRightTab(item,index){
				this.project_stage = item.label;
				this.stage_code = item.value;
				this.stage_select_show = false;
			},
			// 查看项目流程
			async getAdjustList() {
				const res = await this.$myRequest({
					url: 'Project/get_stage_charge',
					method: 'GET',
					data: {
						member_id: this.member_id,
						token: this.token,
						company_id: this.company_id,
						stage_code: this.stage_code,
						project_id: this.project_id,
						project_type: this.project_type,
						permit_type: this.permit_type,
						permit_type_sub: this.permit_type_sub
					}
				});
				if (res.data.code != 200)
					return uni.showToast({
						title: res.data.datas.msg,
						icon: 'none'
					});
				console.log(res)
				this.processList = res.data.datas.list1;
			},
		}
	}
</script>

<style lang="scss">
	.process{
		// width: 200rpx;
		height: auto;
		font-size: 28rpx;
		margin-top: 80rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		.process_item{
			height: 60rpx;
			background-color: #40A0F2;
			color: #FFFFFF;
			text-align: center;
			line-height: 60rpx;
			border-radius: 20rpx;
		}
		.botLine{
			width: 5rpx;
			height: 60rpx;
			background-color: #007AFF;
		}
	}
	
	
	.query_btn{
		width: 300rpx;
		height: 60rpx;
		color: #FFFFFF;
		background-color: #40A0F2;
		text-align: center;
		line-height: 60rpx;
		margin-left: 30%;
		margin-top: 20rpx;
		border-radius: 10rpx;
	}
	.department_select{
		width: 300rpx;
		height: auto;
		font-size: 28rpx;
		position: absolute;
		left: 28%;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		box-shadow: 2rpx 3rpx 20rpx 0rpx rgba(0, 0, 0, 0.2);
		.item{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-bottom: 1rpx solid #CCCCCC;
		}
	}
	.top_card_line{
		width: 580rpx;
		height: auto;
		margin-left: 80rpx;
		border-bottom: 1rpx solid #CCCCCC;
		margin-top: 25rpx;
		padding-bottom: 10rpx;
		text-align: center;
		font-size: 28rpx;
	}
	.stage_select{
		width: 500rpx;
		height: 400rpx;
		font-size: 28rpx;
		position: absolute;
		display: flex;
		flex-direction: row;
		background-color: #FFFFFF;
		margin-left: 25%;
		box-shadow: 2rpx 3rpx 20rpx 0rpx rgba(0, 0, 0, 0.2);
	}
	.stage_select_left{
		width: 50%;
		height: 100%;
		border-right: 1rpx solid #E3E3E3;
		.left_line{
		margin-left: 20rpx;
		margin-top: 20rpx;
		}
	}
	.stage_select_right{
		width: 50%;
		height: 100%;
		.left_line{
		margin-left: 20rpx;
		margin-top: 20rpx;
		}
	}
</style>
